<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>show</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        .container {
            display: flex;
            flex-wrap: wrap;
            padding: 15px;
        }

        .img {
            width: 150px;
            height: 150px;
            object-fit: cover;
            display: inline-block;
            margin: 5px;
        }

        .btn {
            background: linear-gradient(135deg, #abcdf0 10%, #3b8ddf 90%);
            display: inline-block;
            color: #fff;
            border: none;
            padding: 10px 18px;
            outline: none;
            border-radius: 8px;
            transition: all .3s cubic-bezier(0.075, 0.82, 0.165, 1);
            cursor: pointer;
            margin-left: 15px;
        }

        .btn:hover {
            background: linear-gradient(135deg, #88baec 10%, #1f80e0 90%);
        }
    </style>
</head>

<body>
    <div class="container">
        <img src="https://www.eveningwater.com/img/rabbits/rabbit-1.png" alt="" class="img">
        <img src="https://www.eveningwater.com/img/rabbits/rabbit-2.png" alt="" class="img">
        <img src="https://www.eveningwater.com/img/rabbits/rabbit-3.png" alt="" class="img">
        <img src="https://www.eveningwater.com/img/rabbits/rabbit-4.png" alt="" class="img">
        <img src="https://www.eveningwater.com/img/rabbits/rabbit-5.png" alt="" class="img">
        <img src="https://www.eveningwater.com/img/rabbits/rabbit-6.png" alt="" class="img">
    </div>
    <button type="button" id="btn" class="btn">隐藏图片</button>
    <script>
        const btn = document.querySelector('#btn');
        const imgList = document.querySelectorAll('.img');
        const show = (...el) => [...el].forEach(item => (item.style.display = ''));
        const hide = (...el) => [...el].forEach(item => (item.style.display = 'none'));
        let status = false;
        const showOrHide = (elements) => {
            status = !status;
            if (status) {
                hide(...elements);
                btn.textContent = '显示图片';
            } else {
                show(...elements);
                btn.textContent = '隐藏图片';
            }
        }
        btn.addEventListener('click', () => showOrHide(imgList))
    </script>
</body>

</html>